<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@page import="weaver.general.Util"%>
<%
String id = Util.null2String(request.getParameter("id"));
%>
<html>
<head>
<title>调查结果报表</title>
</head>
<body>
<div id="vote_report" class="page out surveyreport-content">
	<style type="text/css">
		#vote_report .content{top:0px;}
		#vote_report .popup{
			position: absolute;
			top: 0px;
			left: 0px;
			bottom: 0px;
			width:100%;
			background-color:#fff;
			z-index: 100000;
			display: none;
		}
		#vote_report .popup-header{
			position: absolute;
		    background-color: #0161c9;
		    text-align: center;
		    top: 0px;
		    left: 0px;
		    right: 0px;
		    height: 36px;
		    line-height: 36px;
		    color: #fff;
		    font-size: 16px;
		}
		#vote_report .popup-header a{
			position: absolute;
		    cursor: pointer;
		    height: 36px;
		    font-size: 14px;
		    width: 36px;
		    background-repeat: no-repeat;
		    background-position: center;
		    margin: 0 5px;
		}
		#vote_report .popup-header a.close-btn{
		    background-image: url("/mobilemode/js/imgdrawing/images/1.png");
		    background-size: 32px;
		    top:0px;
		    right: 0px;
		}
		#vote_report .content-block{
			position: absolute;
		    top: 36px;
		    left: 0px;
		    right: 0px;
		    bottom: 0px;
		    background-color:#fff;
		    overflow: auto; 
		    -webkit-overflow-scrolling: touch;
		}
	</style>
	<div class="content">
		<div id="surveyreport">
            <!--标题区域-->
            <div class="surveytitle">
              <h2 class="votetitle"></h2>
            </div>
            <div class="questions questionsclone">
              <div class="subcompanyname"></div>
              <!--组合选择-->
              <div class="question  matrixclone">
                <div class="questiondetail">
                  <span class="i i_detail_gray"></span>
                </div>
                <div class="subject">
                  <span class="questiontitle"></span>
                  <span class="rules"></span>
                </div>
                <div>
                  <table class="result">
                    <thead></thead>
                    <tbody></tbody>
                  </table>
                </div>
              </div>
              <!--选择-->
              <div class="question selectsignalclone">
                <div class="questiondetail">
                  <span class="i i_detail_gray"></span>
                </div>
                <div class="subject">
                  <span class="questiontitle"></span>
                  <span class="rules"></span>
                </div>
                <div>
                  <table class="result">
                    <colgroup>
                      <col>
                      <col style="width: 50px">
                      <col style="width: 160px">
                    </colgroup>
                    <thead>
                      <tr>
                        <th class="first">选项</th>
                        <th>票数</th>
                        <th>百分比</th>
                      </tr>
                    </thead>
                    <tbody></tbody>
                  </table>
                </div>
              </div>
              <!--填空题-->
              <div class="question blankfillingclone">
                <div class="subject">
                  <span class="questiontitle"></span>
                  <span class="rules"></span>
                </div>
                <div>
                  <div class="blankfilldetail"></div>
                </div>
              </div>
            </div>
          </div>
          
          <div class="votingpersondata"></div>
	</div>
	<!--填空查看弹出框-->
    <div class="popup popup-about">
		<div class="popup-header">
			详细信息
			<a href="javascript:void(0);" class="close-btn"></a>
		</div>
      <div class="content-block"></div>
    </div>
	<script type="text/javascript">
	$.extend(Vote, {
		buildReportPage : function(id){
			var that = this;
			var $page = $("#vote_report");
			
			var $popup = $(".popup", $page);
			
			
			var $closeBtn = $(".close-btn", $popup);
			$closeBtn.click(function(){
				$popup.removeClass("slideup-in");
				$popup.addClass("slideup-out");
			});
			
			var isWebkit = 'WebkitAppearance' in document.documentElement.style || typeof document.webkitHidden != "undefined";
			var animateEventName = isWebkit? "webkitAnimationEnd": "animationend";
			$popup[0].addEventListener(animateEventName, function() {
				if($(this).hasClass("slideup-out")){
					$popup.hide();
					$popup.removeClass("slideup-out");
				}
			});
			
			var url = "/mobilemode/apps/e-cology/vote/voteAction.jsp";
			
			function init(votepages) {
				that.ajax(url, {"operate": "getVotingResult", "votingid": id}, function(data){ 
					var votersitems = data.votersobj;
					var optionvoteritems = data.optionvoters;
					var subcompanyid=["-1"];
					var subnames=[""];
					var novotingperson = data.novotingperson;
					var votingperson = data.votingperson;
					surveyresult.setVotingid(id);
					surveyresult.setOpters(optionvoteritems);
					
					for(var i=0;i<votersitems.length;i++){
						surveyresult.addQuestionsContainer(subcompanyid[i],subnames[i]);
						surveyresult.generatorAllQuestion(votepages);
						surveyresult.generatorAllQuesitonRs(votersitems[i]);   
					}
					surveyresult.registerQestionDetail();
					
					var html = 
						"<table class=\"result\">" +
						"  <thead>" +
						"    <th><div align=\"left\">已投票人</div></th>" +
						"  </thead>" +
						"  <tr>" +
						"    <td style=\"text-align: left;color: #08C;\">";
						
					for(var i = 0; i < votingperson.length; i++) {
						html += votingperson[i] + "&nbsp;&nbsp;";
					}
					html += 
						"    </td>" +
					 	"  </tr>" +
					 	"  <thead>" +
						"    <th><div align=\"left\">未投票人</div></th>" +
					 	"  </thead>" +
					 	"  <tr>" +
						"    <td style=\"text-align: left;color: #666;\">";
					for(var i = 0; i < novotingperson.length; i++) {
						html += novotingperson[i] + "&nbsp;&nbsp;";
					}
					html += 
						"    </td>" +
					 	"  </tr>" +
						"</table>";
					$(".votingpersondata").html(html);
				});
			}
			
			that.ajax(url, {"operate": "checkViewResultPermission", "votingid": id}, function(data){
				if (data.flag) {
					that.ajax(url, {"operate": "getVotingById", "votingid": id}, function(data){
						init(data.voteinfo.votepages);
					});
				}else{
					alert("对不起，您无权查看调查结果！");
					history.go(-1);
				}
			});
			
		}
	});
	Vote.buildReportPage("<%=id%>");
	</script>
</div>
</body>
</html>
